<template>
   <div class="box">
            <div class="title">任务列表</div>
            <div class="list">
                <div :class="{unfinished:item.status==false}" class="task" v-for="(item,index) in arr" :key="index">
                    <div>
                        <span><input type="checkbox" @click="check(item)" :checked="item.statu"></span>
                        <span>{{item.id}}</span>
                        <span>{{item.name}}</span>
                    </div>
                </div>
                <div v-show="arr.length==0" class="empty">任务列表为空,请添加一个任务!</div>
            </div>
     </div>
</template>

<script>
export default {
data(){
    return {
        arr:this.$store.state.toList
    }
},
methods:{
    check(item){
        this.$store.commit('changeStatus',item)
    },
}
}
</script>

<style lang="scss" scoped>
.box .title {
            font-weight: bold;
            line-height: 40px;
        }

        .box .list .task {
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-left: 10px;
            margin: 10px 0;
            background-color: lightseagreen;
            line-height: 40px;
        }

        .box .list .task.unfinished {
            background-color: red;
        }

        .box .list .task span {
            display: inline-block;
            margin-right: 10px;
        }

        .empty {
            text-align: center;
            padding: 50px 0;
        }
</style>